CREATE TABLE [dbo].[tb_GrupoDeCarreras]
(
[idGrupoCarrera] [int] NOT NULL IDENTITY(1, 1),
[descripcion] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Mnemo] [varchar] (7) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updatetb_GrupoDeCarreras] ON [dbo].[tb_GrupoDeCarreras]
 FOR UPDATE AS 
SET NOCOUNT ON
 IF (update(idGrupoCarrera)) begin 
	 SELECT * FROM inserted 
	 IF @@ROWCOUNT = 1 begin 
		 UPDATE tb_RelGrupoCarrera_Carrera
		 SET idGrupoCarrera = (SELECT idGrupoCarrera FROM inserted)
		 WHERE tb_RelGrupoCarrera_Carrera.idGrupoCarrera = (SELECT idGrupoCarrera FROM deleted)
		 UPDATE tb_Divisiones
		 SET GrupoCarreras = (SELECT idGrupoCarrera FROM inserted)
		 WHERE tb_Divisiones.GrupoCarreras = (SELECT idGrupoCarrera FROM deleted)
	end  ELSE begin 
		 ROLLBACK TRANSACTION 
 end 
 end

GO
ALTER TABLE [dbo].[tb_GrupoDeCarreras] ADD CONSTRAINT [PK_tb_GrupoDeCarreras] PRIMARY KEY NONCLUSTERED  ([idGrupoCarrera]) ON [PRIMARY]
GO
